//
//  SubSucViewController.m
//  ZPIOSEducation
//
//  Created by Encoder on 17/1/18.
//  Copyright © 2017年 mini1. All rights reserved.
//

#import "SubSucViewController.h"
#import "ZPMineOrderViewController.h"
#import "ZPConfirmOrderViewController.h"
@interface SubSucViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *imageV;
@property (weak, nonatomic) IBOutlet UILabel *stateL;
@property (weak, nonatomic) IBOutlet UILabel *payFailL;
@property (weak, nonatomic) IBOutlet UILabel *moneyL;
@property (weak, nonatomic) IBOutlet UIView *failV;
@property (weak, nonatomic) IBOutlet UILabel *orderSnL;

@end

@implementation SubSucViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    _moneyL.text = [NSString stringWithFormat:@"支付金额：%@",_needPay];
    _orderSnL.text = [NSString stringWithFormat:@"订单号：%@",_orderSn];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"zhenpin_back"] style:UIBarButtonItemStylePlain target:self action:@selector(backButtonClick)];
    if (_issuscess) {
        [self success];
    }else{
        [self fail];
    }
}

- (void)backButtonClick
{
    ZPMineOrderViewController *vc=[[ZPMineOrderViewController alloc]init];
    vc.isFromPaySuc = YES;
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)success{
    _imageV.highlighted=NO;
    _stateL.text = @"订单支付成功";
    _payFailL.hidden=YES;
    _moneyL.hidden=NO;
    _failV.hidden=YES;
}


-(void)fail{
    _imageV.highlighted=YES;
    _stateL.text = @"抱歉，支付回调失败";
    _payFailL.hidden=NO;
    _moneyL.hidden = YES;
    _failV.hidden = NO;
}
- (IBAction)backhome:(id)sender {
    [((UITabBarController *)self.view.window.rootViewController) setSelectedIndex:0];

    [self.navigationController popToRootViewControllerAnimated:NO];
}
- (IBAction)orderDetai:(id)sender {
    ZPConfirmOrderViewController  *viewController = [[ZPConfirmOrderViewController  alloc] initWithNibName:@"ZPConfirmOrderViewController" bundle:nil];
    viewController.orderSn = _orderSn;
    [self.navigationController pushViewController:viewController animated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
- (IBAction)orderlist:(id)sender {
    ZPMineOrderViewController *vc=[[ZPMineOrderViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}

@end
